package com.qf.j2105.service.impl;

import com.qf.j2105.mapper.AddresDetaiedMapper;
import com.qf.j2105.mapper.AddresMapper;
import com.qf.j2105.mapper.CheBiaoMapper;
import com.qf.j2105.mapper.CheXiMapper;
import com.qf.j2105.po.Addres;
import com.qf.j2105.po.CheBiao;
import com.qf.j2105.service.AddresService;
import com.qf.j2105.vo.AddresInfoVo;
import com.qf.j2105.vo.AdresVo;
import com.qf.j2105.vo.CheXiVo;

import com.qf.j2105.vo.ChebiaoVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AddressServiceImpl implements AddresService {
    @Resource
    private AddresMapper addresMapper;
    @Resource
    private AddresDetaiedMapper addresDetaiedMapper;

    @Resource
    private CheBiaoMapper cheBiaoMapper;

    @Resource
    private CheXiMapper cheXiMapper;

    @Override
    public List<Addres> findAddress() {
        List<Addres> all = addresMapper.findAll();
        for (int i = 0; i < all.size(); i++) {
            Addres addres = all.get(i);
            List<AddresInfoVo> arr = addresDetaiedMapper.findByid(addres.getId());
            addres.setArr(arr);
        }
        System.out.println("all = " + all);
        return all;
    }

    @Override
    public List<AdresVo> findChebiao() {
        List<AdresVo> adres = addresMapper.findAdres();

        for (int i = 0; i < adres.size(); i++) {
            AdresVo adresVo = adres.get(i);
            List<ChebiaoVo> byid = cheBiaoMapper.findByid(adresVo.getId());
            adresVo.setArr(byid);
        }
        return adres;
    }

    @Override
    public List<CheXiVo> findChexi(String name) {
        CheBiao byname = cheBiaoMapper.findByname(name);
        System.out.println("byname = " + byname);
        Integer id = byname.getId();
        List<CheXiVo> byid = cheXiMapper.findByid(id);


        return byid;
    }


}
